<!DOCTYPE html>
<%@ page language="java" pageEncoding="UTF-8"  contentType="text/html;charset=UTF-8"%>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="renderer" content="webkit"><meta http-equiv="X-UA-Compatible" content="IE=8,IE=9,IE=10" />
<meta http-equiv="Expires" content="0"><meta http-equiv="Cache-Control" content="no-cache"><meta http-equiv="Cache-Control" content="no-store">

<script src="${ctxStatic}/jquery/jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="${ctxStatic}/jquery/jquery.form.js" type="text/javascript"></script>
<script src="${ctxStatic}/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
<script src="${ctxStatic}/jquery-validation/1.11.0/jquery.validate.min.js" type="text/javascript"></script>
<script src="${ctxStatic}/uploadify/jquery.uploadify.3.2.edited.js"></script>
<script src="${ctxStatic}/jquery/jquery-ui.min.js"></script>
<link href="${ctxStatic}/jquery-jbox/2.3/Skins/Blue/jbox.css" rel="stylesheet" />
<script src="${ctxStatic}/jquery-jbox/2.3/jquery.jBox-2.3.min.js" type="text/javascript"></script>

<link rel="stylesheet" href="${ctxStatic}/css/formalize.css" />
<link rel="stylesheet" href="${ctxStatic}/css/page.css" />
<link rel="stylesheet" href="${ctxStatic}/css/default/imgs.css" />
<link rel="stylesheet" href="${ctxStatic}/css/reset.css" />
<link type="text/css" href="${ctxStatic}/css/flick/jquery-ui-1.8.18.custom.css" rel="stylesheet" />
<link rel="stylesheet" href="${ctxStatic}/css/uploadify.css" type="text/css" />
<link href="${ctxStatic}/jquery-validation/1.11.0/jquery.validate.min.css" type="text/css" rel="stylesheet" />

<style>
.error{
	font-size: 13px;
}
</style>

<script>
var Global = {
	_ruleTypeId : '1',
	_ticket : '${sessionScope.userId}'+'_1'
};

function bindAttach(modelName,_id,_attachIds){
	$.ajax({
	        async: false,
	        url : "${ctx}/api/attach/bind",
	        type : 'post',
	        data: "&modelName="+modelName+"&modelId="+_id+"&attachIds="+_attachIds,
	        success: function(data, status, xhr) {
	            
	        },
	       error:function(XMLHttpRequest, textStatus, errorThrown){
	       //alert(XMLHttpRequest+"save失败");
	       }
	});
}

function bindRelation(_pId, _pType, _nId, _nType){
	if(typeof(_pId) == "undefined" || !_pId
		|| typeof(_pType) == "undefined" || !_pType
		|| typeof(_nId) == "undefined" || !_nId
		|| typeof(_nType) == "undefined" || !_nType){
		return;
	}			
	$.ajax({
	        async: false,
	        url : "${ctx}/api/relation/bind?r="+Math.random(),
	        type : 'post',
	        data: {
	        	pId : _pId,
	        	pType : _pType,
	        	nId : _nId,
	        	nType : _nType,
	        	ruleTypeId : Global._ruleTypeId
	        },
	        success: function(data, status, xhr) {
	            
	        },
	       error:function(XMLHttpRequest, textStatus, errorThrown){
	       //alert(XMLHttpRequest+"save失败");
	       }
	});
}

function rebindRelation(_pId, _pType, _nId, _nType, _pIdNew, _pTypeNew){
	if(typeof(_pId) == "undefined" || !_pId
		|| typeof(_pType) == "undefined" || !_pType
		|| typeof(_nId) == "undefined" || !_nId
		|| typeof(_nType) == "undefined" || !_nType
		|| typeof(_pIdNew) == "undefined" || !_pIdNew
		|| typeof(_pTypeNew) == "undefined" || !_pTypeNew
		|| _pId == _pIdNew){
		return;
	}			
	$.ajax({
	        async: false,
	        url : "${ctx}/api/relation/rebind?r="+Math.random(),
	        type : 'post',
	        data: {
	        	pId : _pId,
	        	pType : _pType,
	        	nId : _nId,
	        	nType : _nType,
	        	pTypeNew : _pTypeNew,
	        	pIdNew : _pIdNew,
	        	ruleTypeId : Global._ruleTypeId
	        },
	        success: function(data, status, xhr) {
	            
	        },
	       error:function(XMLHttpRequest, textStatus, errorThrown){
	       //alert(XMLHttpRequest+"save失败");
	       }
	});
}
</script>